//============================================================================
// Copyright (C) 2009-2013 Brett R. Jones 
// All Rights Reserved
//
// You may redistribute and/or modify for non commercial and commercial uses 
// provided this copyright notice remains in place and is not modified
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================
 
#include <stdarg.h>
#include <stdio.h>
#include "RcSysSktMgrLib.h"

//============================================================================
//! called if hacker offense is detected
RCODE RcSysSktMgr::HackerOffense(	VxNetIdent *		poContactIdent,			// users identity info ( may be null if not known then use ipAddress )
									U32					u32HackLevel,			// 1=severe 2=medium 3=suspicious
									VxInetAddress		oIpAddrIn,			// ip address if identity not known
									const char *		pMsg, ... )				// message about the offense
{
	//build message on stack so no out of memory issue
	char szBuffer[4096];
	va_list argList;
	va_start(argList, pMsg);
	vsnprintf(szBuffer, sizeof( szBuffer ), pMsg, argList);
	szBuffer[ sizeof( szBuffer ) - 1] = 0;
	va_end(argList);
	VxInetAddress oIpAddr = oIpAddrIn;
	if( poContactIdent )
	{
		oIpAddr = poContactIdent->getOnlineIpAddress();
	}

	std::string strIp = oIpAddr.toStdString();
	log_msg( LOG_SEVERE, "Hacker Offense severity %d: ip %s %s\n", u32HackLevel, strIp.c_str(), szBuffer );
	// what to do here??? guess just notify user
//	wxMessageBox(	szBuffer,							// content
//					"Hack May Have Been Attempted", 	// title
//					wxICON_ERROR | wxICON_STOP);		// icons
	return 0;
}
